var INC = 10;

function checkCallback(res) {
  var resNum = parseInt(res);
  if (resNum < 10 && resNum > -10) return;
  var isNegative = parseInt(res) > 0; // eek!
  var el = $("darth");
  var posStr = el.style.left;
  var pos = posStr.replace(/px/,'');
  var num = parseInt(pos);
  if (isNegative && pos-INC > 30) {
    num -= INC;
  } else if (num+INC < 800) {
    num += INC;
  }
  var newPos = num + "px";
  var debugDiv = $("debug");
  if (debugDiv) debugDiv.innerHTML = "left: " + newPos;
  el.style.left = newPos;
}

function check() {
  sendMsg('AMS', 'checkCallback');
}
